﻿using System.Collections.Generic;
using JetBrains.Annotations;

namespace HurricanePackage
{
    public class UIRootMgr
    {
       [NotNull] private Dictionary<UiRootType, UIRootWnd> m_uiRootDic;

        public UIRootMgr()
        {
            m_uiRootDic = new Dictionary<UiRootType, UIRootWnd>();
        }

        public UIRootWnd GetRoot(UiRootType _type)
        {
            if (m_uiRootDic.TryGetValue(_type, out var root))
                return root;
            else
            {
                switch (_type)
                {
                    case UiRootType.Default:
                        root = new UIRootWnd(new LocalResAssetObject("UI", "UIRoot"), () =>
                        {
                            m_uiRootDic.Put(_type, root);
                        },false);
                        
                        return root;
                    default: return null;
                }
            }
        }
    }
}